//package com.controller;
//
//import java.beans.PropertyVetoException;
//
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.apache.log4j.Logger;
//import org.apache.tomcat.jdbc.pool.DataSource;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
//import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.core.env.Environment;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//import com.mchange.v2.c3p0.ComboPooledDataSource;
//
//@EnableTransactionManagement
//@SpringBootApplication
//@MapperScan("com.dao")
//@ComponentScan(basePackages = "com")
//public class Application {
//    private static Logger logger = Logger.getLogger(Application.class);
//
//    @Autowired
//    private Environment env;
//
//    // DataSource配置
//    @Bean
//    @ConfigurationProperties(prefix = "mysql")
//    public ComboPooledDataSource dataSource() throws Exception {
//        ComboPooledDataSource dataSource = new ComboPooledDataSource();
//        // dataSource.setDriverClass(env.getProperty("mysql.driver"));
//        // dataSource.setJdbcUrl(env.getProperty("mysql.url"));
//        // dataSource.setUser(env.getProperty("mysql.username"));
//        // dataSource.setPassword(env.getProperty("mysql.password"));
//        // dataSource.setMaxPoolSize(20);
//        // dataSource.setMinPoolSize(5);
//        // dataSource.setInitialPoolSize(10);
//        // dataSource.setMaxIdleTime(300);
//        // dataSource.setAcquireIncrement(5);
//        // dataSource.setIdleConnectionTestPeriod(60);
//        return dataSource;
//    }
//
//    // 提供SqlSeesion
//    @Bean
//    public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
//
//        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//        sqlSessionFactoryBean.setDataSource(dataSource());
//
//        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//
//        sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mappers/*.xml"));
//
//        return sqlSessionFactoryBean.getObject();
//    }
//
//    @Bean
//    public PlatformTransactionManager transactionManager() throws Exception {
//        return new DataSourceTransactionManager(dataSource());
//    }
//
//    @Bean
//    public EmbeddedServletContainerFactory servletContainer() {
//        TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
//        factory.setPort(8087);
//        factory.setContextPath("/springBoot");
//        return factory;
//    }
//
//    /**
//     * Main Start
//     */
//    public static void main(String[] args) {
//        SpringApplication.run(Application.class, args);
//        logger.info("============= SpringBoot Start Success =============");
//    }
//
//}